import { legacy_createStore as createStore, combineReducers } from "redux"; //解决createSstore有删除线的问题可以这样引  combineReducers 合并reducer方法 createStore已经弃用
import { CollapseReducer } from "./reducers/CollapseReducer"; //导入reducer
import { loadingReducer } from "./reducers/loadingReducer"; //导入reducer
import storage from "redux-persist/lib/storage"; //引入store

import { persistStore, persistReducer } from "redux-persist"; //导入持久化

const persistConfig = {
  key: "kerwin", //存到localStore里的名字
  storage, //存到本地
  blacklist: ["loadingReducer"], //黑名单里的东西就不会被持久化
};
//将reducer做一个合并处理，因为store里只能放一个reducer
const reducer = combineReducers({ CollapseReducer, loadingReducer });

//   把reducer函数按照persistConfig这个配置进行持久化
const persistedReducer = persistReducer(persistConfig, reducer);

// 要不这个reducer放在这个store里边作为初始参数
let store = createStore(persistedReducer); //创建store对象
let persistor = persistStore(store);
export { store, persistor };

/*
发布
store.dispatch()

订阅
store.subsribe()
*/
